//package com.douqu.game.auth.platform;
//
//import com.bean.core.util.TwoTuple;
//import com.douqu.game.auth.database.model.RoleRecordModel;
//import com.douqu.game.auth.service.PlayerService;
//import com.douqu.game.core.e.ReturnMessage;
//import com.douqu.game.core.factory.ConstantFactory;
//import com.douqu.game.core.protobuf.SGCommonProto;
//import com.douqu.game.core.util.CoreUtils;
//import com.douqu.game.core.util.LogUtils;
//import com.douqu.game.core.util.YjSdkUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
///**
// * @author: wangzhenfei
// */
//@Component
//public class YJImpl implements PlatformSDK {
//
//    @Autowired
//    private PlayerService playerService;
//
//    @Override
//    public TwoTuple<RoleRecordModel, ReturnMessage> auth(int serverId, String account, String password, String deviceId) {
//        String [] param = password.split(ConstantFactory.DIVISION);
//        String app = null;
//        String sdk = null;
//        String uin = null;
//        String sess = null;
//        try {
//            app = param[0];
//            sdk = param[1];
//            uin = param[2];
//            sess = param[3];
//        } catch (Exception e) {
//            e.printStackTrace();
//            LogUtils.error("参数解析错误:" + password);
//            return new TwoTuple<>(null, ReturnMessage.AUTH_FAILURE);
//        }
//
//        try {
//            if(!YjSdkUtils.checkUserLogin(app, sdk, uin, sess)){
//                return new TwoTuple<>(null, ReturnMessage.AUTH_FAILURE);
//            }
//            account = CoreUtils.createAccount(account, SGCommonProto.E_CHANNEL_TYPE.CHANNEL_TYPE_YJ);
//            RoleRecordModel record = playerService.getUserRecordByAccount(account);
//            if(record == null)
//            {//需要创建
//                record = new RoleRecordModel();
//                record.setAccount(account);
//                record.setChannel(SGCommonProto.E_CHANNEL_TYPE.CHANNEL_TYPE_YJ_VALUE);
//                record.setServerId(serverId);
//                LogUtils.info("易接平台第一次登录，创建用户");
//            }
//            return new TwoTuple<>(record, null);
//
//        } catch (Exception e) {
//            e.printStackTrace();
//            return new TwoTuple<>(null, ReturnMessage.AUTH_FAILURE);
//        }
//    }
//
//    public static void main(String[] args) {
//        System.out.println(CoreUtils.createAccount("133", SGCommonProto.E_CHANNEL_TYPE.CHANNEL_TYPE_YJ));
//    }
//}
